package com.recruit.wechat.serviceImpl;
import com.recruit.wechat.controller.helper.$;
import com.recruit.wechat.controller.model.ApiResultModel;
import com.recruit.wechat.bean.WechatEvaluate;
import com.recruit.wechat.mapper.WechatEvaluateMapper;
import com.recruit.wechat.service.WechatEvaluateService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.recruit.wechat.bean.result.ResultPage;

import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LF
 * @since 2020-08-25
 */
@Service
public class WechatEvaluateServiceImpl extends ServiceImpl<WechatEvaluateMapper, WechatEvaluate> implements WechatEvaluateService {
    /** 添加WechatEvaluate
     * @param wechatEvaluate  前端传进的参数
     * @return 返回统一信息
     */
    @Override
    public ApiResultModel addWechatEvaluate(WechatEvaluate wechatEvaluate  ) {
           if(this.save(wechatEvaluate )){
               return $.success();
           }else{
                return $.error("添加失败");
           }
    }
    /** 编辑跳转页面的回显数据WechatEvaluate
     * @param id  前端传进的参数
     * @return 返回实体类
     */
    @Override
    public WechatEvaluate selectWechatEvaluateByIdWechatEvaluate(Integer id ){
            return this.getById(id);
    }


    /** 编辑WechatEvaluate
     * @param wechatEvaluate  前端传进的参数
     * @return 返回统一信息
     */
    @Override
    public ApiResultModel editWechatEvaluate(WechatEvaluate wechatEvaluate  ) {
           if(this.updateById(wechatEvaluate )){
               return $.success();
           }else{
                return $.error("编辑失败");
           }
    }
    /** 删除一条WechatEvaluate
     * @param id  前端传进的ID
     * @return 返回统一信息
     */
    @Override
    public   ApiResultModel delWechatEvaluate( Integer id  ){
           if(this.removeById(id)){
               return $.success();
           }else{
                return $.error("删除失败");
           }
    }

   /** 分页查询WechatEvaluate
     * @param page  页码
     * @param limit  查几条
     * @param wechatEvaluate  前端传进的参数
     * @return 返回统一分页信息
     */
    @Override
    public  ResultPage findWechatEvaluateByPage(Integer page, Integer limit,WechatEvaluate wechatEvaluate){
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("page", (page - 1) * limit);
        paramMap.put("limit", limit);
        paramMap.put("wechatEvaluate", wechatEvaluate);
        List<WechatEvaluate> list = baseMapper.selectMyPage(paramMap);
        Integer count = baseMapper.countMyPage(paramMap);
        ResultPage<WechatEvaluate> resultPage = new ResultPage<>();
        resultPage.setCode(0);
        resultPage.setCount(count);
        resultPage.setMsg("成功");
        resultPage.setData(list);
        return resultPage;
    }
}
